﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Xml.Linq;

namespace Technewlogic.FileXChange.Common
{
	public class FileMethod
	{
		private FileMethod() { }

		public string Name { get; private set; }

		private static FileMethod _get = new FileMethod() { Name = "get" };
		public static FileMethod Get
		{
			get { return _get; }
		}

		private static FileMethod _delete = new FileMethod() { Name = "delete" };
		public static FileMethod Delete
		{
			get { return _delete; }
		}

		private static FileMethod _put = new FileMethod() { Name = "put" };
		public static FileMethod Put
		{
			get { return _put; }
		}

		public static FileMethod Parse(string methodName)
		{
			if (methodName == null)
				methodName = string.Empty;

			switch (methodName.ToLower())
			{
				case "get":
					return Get;
				case "delete":
					return Delete;
				case "put":
					return Put;
				default:
					throw new ApplicationException("The method '" + methodName + "' is unknown - only Get, Put and Delete are allowed.");
			}
		}
	}
}
